package business.sale.entities;

import java.util.ArrayList;

import sale.entities.OrderVO;
import article.entities.ArticleVO;
import business.article.entities.Article;

public class Order {

	private int primaryKey;
	private boolean isReady;
	private ArrayList<Article> arts = new ArrayList<Article>();
	private ArrayList<String> especif;
	private int tableKey;
	private String address;
	private String tel;

	public ArrayList<Article> getArts() {
		return arts;
	}

	public ArrayList<String> getEspecif() {
		return especif;
	}

	public void setEspecif(ArrayList<String> esp) {
		this.especif = esp;
	}

	public Order(ArrayList<Article> arts2) {
		this.arts = arts2;
	}

	public void addArticle(Article arg0) {
		this.arts.add(arg0);
	}

	public int getPrimaryKey() {
		return primaryKey;
	}

	public void setPrimaryKey(int primaryKey) {
		this.primaryKey = primaryKey;
	}

	public boolean isReady() {
		return isReady;
	}

	public void setReady(boolean isReady) {
		this.isReady = isReady;
	}

	public int getTableKey() {
		return tableKey;
	}

	public void setTableKey(int tableKey) {
		this.tableKey = tableKey;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public void setArts(ArrayList<Article> arts) {
		this.arts = arts;
	}

	public Order(OrderVO ord) {
		if (ord != null) {
			this.primaryKey = ord.getPrimaryKey();
			this.especif = ord.getEspecif();
			this.address = ord.getAddress();
			this.isReady = ord.isReady();
			this.tableKey = ord.getTableKey();
			this.tel = ord.getTel();
			for (ArticleVO o : ord.getArts()) {
				this.arts.add(new Article(o));
			}
		}
	}
	public OrderVO toVO() {
		ArrayList<ArticleVO> temp = new ArrayList<ArticleVO>();
		for (Article o : this.arts)
			temp.add(o.toVO());
		return new OrderVO(this.primaryKey, this.isReady, temp, this.especif,
				this.tableKey, this.address, this.tel);
	}
	public Order(ArrayList<Article> arts, ArrayList<String> especif) {
		//se usa para agregar una nueva orden a una sale ya existente
		this.arts = arts;
		this.especif = especif;
	}

	public Order(int primaryKey, boolean isReady, ArrayList<Article> arts,
			ArrayList<String> especif, int tableKey) {
		this.primaryKey = primaryKey;
		this.isReady = isReady;
		this.arts = arts;
		this.especif = especif;
		this.tableKey = tableKey;
	}
	
	
}
